package com.example.controller;

import com.alibaba.fastjson.JSONObject;
import com.example.annotations.Autowired;
import com.example.annotations.PostMapping;
import com.example.annotations.RequestBody;
import com.example.annotations.RouteMapping;
import com.example.db.DBSql;
import com.example.utils.Results;


import java.util.Map;

/**
 * @Classname TableController
 * @Description TODO
 * @Date 2022/5/27 21:44
 * @Created by XiongXiong
 * @Author: X.I.O
 */
@RouteMapping("/table")
public class TableController {

    @Autowired
    private DBSql dbSql;

    @PostMapping("/insert")
    public JSONObject tableController(@RequestBody Map<String,Object> object){
        String tableName=String.valueOf(object.get("tableName"));
        Map<String,Object> objectMap=(Map<String, Object>) object.get("map");
        dbSql.insert(tableName,objectMap);
        return Results.success("新增成功");
    }

    @PostMapping("/upload")
    public JSONObject uploadFile(){
      return Results.success("文件上传");
    }
}
